package com.xmg.p2p.base.controller;

import com.xmg.p2p.base.domain.Logininfo;
import com.xmg.p2p.base.query.IplogQueryObject;
import com.xmg.p2p.base.query.PageResult;
import com.xmg.p2p.base.service.IIplogService;
import com.xmg.p2p.base.util.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class IplogController {
    @Autowired
    private IIplogService iplogService;


    @RequestMapping("iplog_list")
    public String iplogList(@ModelAttribute("qo") IplogQueryObject qo, Model model){
        try {
            Logininfo current = UserContext.getCurrent();
            qo.setUsername(current.getUsername());
            qo.setUserType(Logininfo.USER_CLIENT);
            PageResult pageResult = iplogService.query(qo);
            model.addAttribute("pageResult", pageResult);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "iplog_list";
    }
}
